//import pathToRegexp from 'path-to-regexp';
import { hotwordsAll } from './api';
import { Toast } from 'antd-mobile';

export default {
    namespace: 'gotosearch',
    state: {
        list:[]
    },
    reducers: {
        save(state, { data }) {
            return { ...state, ...data };
        },
    },
    effects: {
        *gethotwordsAllEFF({ }, { put, call }) {
            Toast.loading('加载中...', 3);
            const result = yield call(hotwordsAll);
            if (result.code == 200) {
                yield put({ type: 'save', data: result.ret });
                Toast.hide();
            } else {

            }
        },
    },
    subscriptions: {
        setup({ dispatch, history }) {
            return history.listen(({ pathname, query }) => {
                //console.log(pathname);
                if (pathname == '/gotosearch') {
                    dispatch({ type: 'gethotwordsAllEFF' });
                   // dispatch({ type: 'recommendEFF' });
                }
            });
        },
    },
};
